home *** CD-ROM | disk | FTP | other *** search
-
-
-
- ooooppppeeeennnn((((DDDD2222)))) ooooppppeeeennnn((((DDDD2222))))
-
-
-
- NNNNAAAAMMMMEEEE
- _oooo_pppp_eeee_nnnn - gain access to a device
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- BBBBlllloooocccckkkk aaaannnndddd CCCChhhhaaaarrrraaaacccctttteeeerrrr SSSSyyyynnnnooooppppssssiiiissss
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_tttt_yyyy_pppp_eeee_ssss_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_ffff_iiii_llll_eeee_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_eeee_rrrr_rrrr_nnnn_oooo_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_oooo_pppp_eeee_nnnn_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_cccc_rrrr_eeee_dddd_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_dddd_dddd_iiii_...._hhhh_>>>>
- _iiii_nnnn_tttt _p_r_e_f_i_x_oooo_pppp_eeee_nnnn_((((_dddd_eeee_vvvv______tttt _****_d_e_v_p_,,,, _iiii_nnnn_tttt _o_f_l_a_g_,,,, _iiii_nnnn_tttt _o_t_y_p_,,,, _cccc_rrrr_eeee_dddd______tttt _****_c_r_p_))))_;;;;
-
- BBBBlllloooocccckkkk aaaannnndddd CCCChhhhaaaarrrraaaacccctttteeeerrrr AAAArrrrgggguuuummmmeeeennnnttttssss
- _d_e_v_p Pointer to a device number.
-
- _o_f_l_a_g
- Information passed from the user that instructs the driver on how to
- open the file.
-
- _o_t_y_p Parameter supplied so that the driver can determine how many times a
- device was opened and for what reasons.
-
- _c_r_p Pointer to the user credential structure.
-
- SSSSTTTTRRRREEEEAAAAMMMMSSSS SSSSyyyynnnnooooppppssssiiiissss
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_tttt_yyyy_pppp_eeee_ssss_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_ffff_iiii_llll_eeee_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_ssss_tttt_rrrr_eeee_aaaa_mmmm_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_eeee_rrrr_rrrr_nnnn_oooo_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_cccc_rrrr_eeee_dddd_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_dddd_dddd_iiii_...._hhhh_>>>>
- _iiii_nnnn_tttt _p_r_e_f_i_x_oooo_pppp_eeee_nnnn_((((_qqqq_uuuu_eeee_uuuu_eeee______tttt _****_q_,,,, _dddd_eeee_vvvv______tttt _****_d_e_v_p_,,,, _iiii_nnnn_tttt _o_f_l_a_g_,,,, _iiii_nnnn_tttt _s_f_l_a_g_,,,, _cccc_rrrr_eeee_dddd______tttt _****_c_r_p_))))_;;;;
-
- SSSSTTTTRRRREEEEAAAAMMMMSSSS AAAArrrrgggguuuummmmeeeennnnttttssss
- _q Pointer to the queue used to reference the read side of the driver.
-
- _d_e_v_p Pointer to a device number. For modules, _d_e_v_p always points to the
- device number associated with the driver at the end (tail) of the
- stream.
-
- _o_f_l_a_g
- Open flags.
-
- _s_f_l_a_g
- STREAMS flag.
-
- _c_r_p Pointer to the user credential structure.
-
-
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- ooooppppeeeennnn((((DDDD2222)))) ooooppppeeeennnn((((DDDD2222))))
-
-
-
- RRRReeeettttuuuurrrrnnnn VVVVaaaalllluuuueeeessss
- The _oooo_pppp_eeee_nnnn routine should return 0 for success, or the appropriate error
- number.
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- BBBBlllloooocccckkkk aaaannnndddd CCCChhhhaaaarrrraaaacccctttteeeerrrr DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- The driver's _oooo_pppp_eeee_nnnn routine is called to prepare a device for further
- access. It is called by the kernel during an _oooo_pppp_eeee_nnnn(2) or a _mmmm_oooo_uuuu_nnnn_tttt(2) of
- the device special file. For non-STREAMS drivers, it can also be called
- from another (layered) driver.
-
- The bit settings for _oooo_ffff_llll_aaaa_gggg are found in _ffff_iiii_llll_eeee_...._hhhh. Valid settings are:
-
- _FFFF_EEEE_XXXX_CCCC_LLLL Interpreted in a driver-dependent manner. Some drivers
- interpret this flag to mean open the device with
- exclusive access (fail all other attempts to open the
- device.)
-
- _FFFF_NNNN_DDDD_EEEE_LLLL_AAAA_YYYY Open the device and return immediately without sleeping
- (do not block the open even if there is a problem.)
-
- _FFFF_NNNN_OOOO_NNNN_BBBB_LLLL_OOOO_CCCC_KKKK Open the device and return immediately without sleeping
- (do not block the open even if there is a problem.)
-
- _FFFF_RRRR_EEEE_AAAA_DDDD Open the device with read access permission.
-
- _FFFF_WWWW_RRRR_IIII_TTTT_EEEE Open the device with write access permission.
-
- Valid values for _o_t_y_p are defined in _oooo_pppp_eeee_nnnn_...._hhhh. The values are mutually
- exclusive:
-
- _OOOO_TTTT_YYYY_PPPP______BBBB_LLLL_KKKK Open occurred through block interface for the device.
-
- _OOOO_TTTT_YYYY_PPPP______CCCC_HHHH_RRRR Open occurred through the raw/character interface for
- the device.
-
- _OOOO_TTTT_YYYY_PPPP______LLLL_YYYY_RRRR Open a layered device. This flag is used when one
- driver calls another driver's _oooo_pppp_eeee_nnnn routine.
-
- SSSSTTTTRRRREEEEAAAAMMMMSSSS DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- The STREAMS module _oooo_pppp_eeee_nnnn routine is called by the kernel during an _IIII______PPPP_UUUU_SSSS_HHHH
- _iiii_oooo_cccc_tttt_llll(2).
-
- Values for _o_f_l_a_g are the same as those described for the block and
- character open flags above.
-
- The values for _s_f_l_a_g are mutually exclusive:
-
- _CCCC_LLLL_OOOO_NNNN_EEEE_OOOO_PPPP_EEEE_NNNN Indicates a clone open (see below.) If the driver
- supports cloning, it must assign and return a device
- number of an unused device by changing the value of the
- device number to which _d_e_v_p points.
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- ooooppppeeeennnn((((DDDD2222)))) ooooppppeeeennnn((((DDDD2222))))
-
-
-
- _MMMM_OOOO_DDDD_OOOO_PPPP_EEEE_NNNN Indicates that an _oooo_pppp_eeee_nnnn routine is being called for a
- module, not a driver. This is useful in detecting
- configuration errors and in determining how the driver
- is being used, since STREAMS drivers can also be
- configured as STREAMS modules.
-
- _0000 Indicates a driver is being opened directly, without
- cloning.
-
- UUUUSSSSAAAAGGGGEEEE
- This entry point is required in all drivers and STREAMS modules.
-
- The _oooo_pppp_eeee_nnnn routine could perform any of the following general functions,
- depending on the type of device and the service provided:
-
- enable device interrupts
-
- allocate buffers or other resources needed to use the device
-
- lock an unsharable device
-
- notify the device of the open
-
- change the device number if this is a clone open
-
- enable put and service procedures for multithreaded drivers
-
- The _oooo_pppp_eeee_nnnn routine should verify that the minor number component of _d_e_v_p is
- valid, that the type of access requested by _o_t_y_p and _o_f_l_a_g is appropriate
- for the device, and, if required, check permissions using the user
- credentials pointed to by _c_r_p [see _dddd_rrrr_vvvv______pppp_rrrr_iiii_vvvv(D3)].
-
- For STREAMS drivers and modules, the _oooo_pppp_eeee_nnnn routine is called with
- interrupts blocked from all STREAMS devices. If the driver sets stream
- head options by sending an _MMMM______SSSS_EEEE_TTTT_OOOO_PPPP_TTTT_SSSS message upstream from the _oooo_pppp_eeee_nnnn
- routine, then the changes are guaranteed to take effect when the system
- call completes.
-
- Support of cloning is optional. Cloning is the process of the driver
- selecting an unused device for the user. It eliminates the need to poll
- many devices when looking for an unused one. Both STREAMS and Non-
- STREAMS drivers may implement cloning behavior by changing the device
- number pointed to by _d_e_v_p. A driver may designate certain minor devices
- as special clone entry points into the driver. When these are opened,
- the driver searches for an unused device and returns the new device
- number by changing the value of the device number to which _d_e_v_p points.
- Both the major device number and the minor device number can be changed,
- although usually just the minor number is changed. The major number is
- only changed when the clone controls more than one device.
-
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-
-
-
- ooooppppeeeennnn((((DDDD2222)))) ooooppppeeeennnn((((DDDD2222))))
-
-
-
- Using this method of cloning, a STREAMS driver will never see _s_f_l_a_g set
- to _CCCC_LLLL_OOOO_NNNN_EEEE_OOOO_PPPP_EEEE_NNNN. A different method makes use of this flag. STREAMS
- drivers can take advantage of a special driver, known as the _c_l_o_n_e
- _d_r_i_v_e_r, to perform clone opens. This frees the driver from having to
- reserve special minors for the clone entry points. Here, the device node
- is actually that of the clone driver (the major number is the major
- number from the clone driver and the minor number is the major number
- from the real driver.) When the clone driver is opened, it will call the
- real driver open routine with _s_f_l_a_g set to _CCCC_LLLL_OOOO_NNNN_EEEE_OOOO_PPPP_EEEE_NNNN.
-
- For STREAMS drivers and modules, for a given device number (queue), only
- one instance of the _oooo_pppp_eeee_nnnn routine can be running at any given time.
- However, multiple opens on any two different device numbers (queues) can
- be running concurrently. It is the responsibility of the driver or
- module to synchronize access to its private data structures in this case.
- For clone opens, multiple clone opens can run concurrently, and it is the
- driver's responsibility to synchronize access to its private data
- structures, as well as allocation and deallocation of device numbers.
-
- SSSSyyyynnnncccchhhhrrrroooonnnniiiizzzzaaaattttiiiioooonnnn CCCCoooonnnnssssttttrrrraaaaiiiinnnnttttssss
- The _oooo_pppp_eeee_nnnn routine has user context and can sleep. However, STREAMS
- drivers and modules must sleep such that signals do not cause the sleep
- to longjump [see _ssss_llll_eeee_eeee_pppp(D3)].
-
- RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEESSSS
- _cccc_llll_oooo_ssss_eeee(D2), _dddd_rrrr_vvvv______pppp_rrrr_iiii_vvvv(D3), _eeee_rrrr_rrrr_nnnn_oooo_ssss(D5), _qqqq_uuuu_eeee_uuuu_eeee(D4)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 4444
-
-
-
-